# -*- coding: utf-8 -*-
# @Time: 2021/8/13 16:48
# @File: problem-234.py
# @DESC: https://leetcode-cn.com/problems/palindrome-linked-list/
# 回文链表
from list_node_common import ListNode, listToNode


class Solution:
    def isPalindrome(self, head: ListNode) -> bool:
        print("判断是否为回文链表")

        if head == None:
            return False

        cur = head
        data = []
        while cur:
            data.append(cur.val)
            cur = cur.next

        lent = len(data)
        for i in range(lent):
            start = i
            end = lent - 1 - i
            if data[start]!=data[end]:
                return False
        return True


data = [1, 1,3, 1, 1]
l = listToNode(data)
so = Solution()
result = so.isPalindrome(l)
print(result)
